<?php
/**
 * @Author: liuhongbin
 * @Email: 514660094@qq.com
 * @Date: 2019-02-12 16:15:10
 * @Description:
 * @LastEditors: liuhongbin
 * @LastEditTime: xxx
 */

namespace app\common\model\wechat;

use app\common\model\wechat\tralts\WechatModel;
use app\common\services\User;
use hiduoke\services\facade\WechatService as Ws;

class WechatShareReceiver extends WechatBaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'wechat_share_receiver';

    /**
     * 字段类型或者格式转换
     * @var array
     */
    protected $type = [
    ];

    public $append = [

    ];

    public function wechatOrder()
    {
        return $this->belongsTo(WechatOrder::class, 'transaction_id', 'transaction_id');
    }

    public function wechatShare()
    {
        return $this->belongsTo(WechatOrder::class, 'transaction_id', 'transaction_id');
    }

    public function  user(){
        return $this->belongsTo(WechatUser::class,'account','openid');
    }

//    public function getUserAttr($val, $data)
//    {
//        $user = (new WechatUser())->where(['openid' => $data['account']])->find();
//
//    }
}
